﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SaleReturnItems.aspx.cs" Inherits="Main_Inventory_SaleReturnItems" Culture="en-GB" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sales Return Items.</title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">       
        function SelectAll(id,ItemId) {            
            var CurCheckBox = document.getElementById(id);
            var CurItemID = document.getElementById(ItemId).value;
            var DataList = document.getElementById("datalistMain");            
            var grid = DataList.getElementsByTagName("table");
            for (var i = 0; i < grid.length; i++) {
                var tableRow = grid[i].getElementsByTagName("tr");
                for (var j = 1; j < tableRow.length; j++) {
                    var Inputs = tableRow[j].getElementsByTagName("input");
                    var PreCheckBox;
                    if (Inputs[0].type == "checkbox") {
                        PreCheckBox = document.getElementById(Inputs[0].id);
                    }
                    if (Inputs[1].type == "hidden") {
                        var PreItemID = document.getElementById(Inputs[1].id).value;                        
                        if (PreCheckBox != CurCheckBox) {
                            if (CurItemID == PreItemID && PreCheckBox.checked == true) {
                                alert('Please Select Unique Item');
                                CurCheckBox.checked = false;
                                break;
                            }
                        }
                    }
                }
            }
            return true;
        }
        function DisplayData() {
            window.opener.document.getElementById("btnCreateItem").click();
            self.close();
        }
   </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div style="width:90%; margin:5px 5% 10px 5%; background-color:#F2F2F2; border:solid 1px #818181; margin-bottom:10px;">
        <table width="100%" cellpadding="2" cellspacing="0"> 
            <tr>
                <td>
                    Customer Name:
                </td>
                <td>
                    <asp:Label ID="lblCustomer" runat="server" Font-Bold="true"></asp:Label>                   
                </td>
                <td colspan="2">
                   &nbsp;                 
                </td>
            </tr>
            <tr>
                <td>
                   From Date:
                </td>
                <td>
                    <asp:TextBox ID="txtDateFrom" runat ="server" CssClass="input"></asp:TextBox>
                    <AjaxControl:CalendarExtender ID="calDateFrom" runat="server" TargetControlID="txtDateFrom" Format="dd/MM/yyyy" ></AjaxControl:CalendarExtender>                    
                </td>
                <td>
                    To Date:
                </td>
                <td>
                    <asp:TextBox ID="txtDateTo" runat="server" CssClass="input"></asp:TextBox>
                    <AjaxControl:CalendarExtender ID="calDateTo" runat="server" TargetControlID="txtDateTo" Format="dd/MM/yyyy" ></AjaxControl:CalendarExtender>                    
                </td>
            </tr>
             <tr>
                <td colspan="4" align="center">
                    <asp:Button ID="btnShow" runat="server" Text="Show" OnClick="btnShow_Click" CssClass="button" />
                </td>
            </tr>
            <tr>
                <td colspan="4">
                   &nbsp;
                </td>
            </tr>
        </table>
    </div>
    <div style="width:90%; margin-left:5%; margin-right:5%;">
        <asp:DataList ID="datalistMain" runat="server" Width="100%" BorderStyle="Solid" BorderColor="#818181" BorderWidth="1px" OnItemDataBound="datalistMain_ItemBound">
        <ItemTemplate>
            Format Name:&nbsp;
            <asp:Label ID="lblFormat" Font-Bold="true" runat="server" Text='<%#Eval("formatname") %>'></asp:Label>
            <asp:HiddenField ID="hidTranId" runat="server" Value='<%#Eval("trnid") %>' />
            <asp:GridView ID="grdDisplay" AutoGenerateColumns="false" CssClass="gridview" AlternatingRowStyle-CssClass="gridview_alternate" 
                OnRowDataBound="grdDisplay_OnRowDataBound" runat="server" 
                onprerender="grdDisplay_PreRender">
                <Columns>
                    <asp:BoundField HeaderText="Bill Date" DataField="trndate" DataFormatString="{0:dd-MM-yyyy}"/>
                    <asp:BoundField HeaderText="Bill No." DataField="tranumber"/>
                    <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:CheckBox ID="chkItem" runat="server"/>
                            <asp:HiddenField ID="hidItemId" runat="server" Value='<%#Eval("itmid") %>' /> 
                            <asp:HiddenField ID="hidUomId" runat="server" Value='<%#Eval("UOMID") %>' /> 
                            <asp:HiddenField ID="hidUomSymbol" runat="server" Value='<%#Eval("UOMSYMBOL") %>' /> 
                            <asp:HiddenField ID="hidTrnItemId" runat="server" Value='<%#Eval("TITID") %>' />                            
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="Item Code" DataField="itmcode"/>
                    <asp:BoundField HeaderText="Item Description" DataField="itmdesc"/>
                    <asp:BoundField HeaderText="Rate" DataField="rate" DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                    <asp:BoundField HeaderText="Quantity" DataField="itmqty" DataFormatString="{0:0.00}" ItemStyle-HorizontalAlign="Right" />
                </Columns>
            </asp:GridView>
        </ItemTemplate>
        </asp:DataList>
        <div style="text-align:center">
            <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="OK" CssClass="button" />
        </div>
    </div>
    </form>
</body>
</html>
